#include <iostream>
#include <iomanip>
#include <string>
#include "Player.h"
#include "DurationCounter.h"
#include "Song.h"
#include "Album.h"
#include "MusicCollection.h"

//constant separator for printing the medias
static const std::string separator = " << ";

void Player::Visit(Song * song){
	//DurationCounter is created to visit the actual Song
	//to get the duration of it
	DurationCounter duration;
	song->Accept(&duration);
	TDuration songduration = duration.getDuration();
	//print formatted
	std::cout << mPrintnumber++ << ". ";
	std::cout << *song->getName() << separator;
	std::cout << std::setfill('0') << std::setw(2) << songduration.Minutes << ":";
	std::cout << std::setfill('0') << std::setw(2) << songduration.Seconds << separator;
	std::cout << *song->getInterpret() << std::endl;
}

void Player::Visit(Album * album){
	//DurationCounter is created to visit the actual Album
	//to get the duration of it
	DurationCounter duration;
	album->Accept(&duration);
	TDuration albumduration = duration.getDuration();
	//print formatted
	std::cout << "Album: ";
	std::cout << *album->getName();
	//the number of the songs in an album is given by the size of the
	//list which holds all songs
	std::cout << " (" << album->getMedia()->size() << " Songs)" << separator;
	std::cout << std::setfill('0') << std::setw(2) << albumduration.Minutes << ":";
	std::cout << std::setfill('0') << std::setw(2) << albumduration.Seconds << std::endl;
}

void Player::Visit(MusicCollection * collection){
	//DurationCounter is created to visit the actual MusicCollection
	//to get the duration of it
	DurationCounter duration;
	collection->Accept(&duration);
	TDuration collectionduration = duration.getDuration();
	//print formatted
	std::cout << "Collection: ";
	std::cout << *collection->getName();
	//the number of the songs in a music collection is given by the size of the
	//list which holds all songs
	std::cout << " (" << collection->getMedia()->size() << " Songs)" << separator;
	std::cout << std::setfill('0') << std::setw(2) << collectionduration.Minutes << ":";
	std::cout << std::setfill('0') << std::setw(2) << collectionduration.Seconds << std::endl;
}